<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link href="https://cdn.bootcss.com/semantic-ui/2.4.1/semantic.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../../static/css/myCss.css" th:href="@{/css/myCss.css}"  type="text/css">

    <meta name="viewpoint" content="width=device-width, initial-scale=1.0">
    <style>
        html, body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
        body {
            display: flex;
            align-items: center; /*定义body的元素垂直居中*/
            justify-content: center; /*定义body的里的元素水平居中*/
        }
    </style>
    <title>注册</title>
</head>
<body>

<div>
    <div class="ui container" style="max-width: 30em !important; ">
        <div class="ui middle aligned center aligned grid login">
            <div class="column">
                <h2 class="ui teal image header">
                    <div class="content">注册您的账号</div>
                </h2>
                <form class="ui large form" method="post" action="#" th:action="@{/admin/register}">
                    <div class="ui stacked segment">
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="user icon"></i>
                                <input type="text" name="username" placeholder="请输入用户名">
                            </div>
                        </div>
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="user icon"></i>
                                <input type="text" name="nickname" placeholder="请输入昵称">
                            </div>
                        </div>
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="user icon"></i>
                                <input type="text" name="email" placeholder="请输入邮箱">
                            </div>
                        </div>
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="lock icon"></i>
                                <input type="password" name="password" placeholder="请输入密码">
                            </div>
                        </div>
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="lock icon"></i>
                                <input type="password" name="rePassword" placeholder="请再输入一次密码">
                            </div>
                        </div>
                        <button class="ui fluid large teal submit button">注册并登录</button>
                    </div>

                    <div class="ui error message"></div>
                    <div class="ui mini negative message" th:unless="${#strings.isEmpty(message)}" th:text="${message}">用户名和密码错误</div>
                </form>

                <div class="ui message ">
                    已有账户？ <a href="#" th:href="@{/admin}">马上登陆！</a>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
<script>
    var
        $form = $('.ui.form'),
        password = $form.form('get value', 'password')
    ;
    console.log(password)
    $('.ui.form').form({
        fields : {
            username : {
                identifier: 'username',
                rules: [{
                    type : 'empty',
                    prompt: '请输入用户名'
                }]
            },
            nickname : {
                identifier: 'nickname',
                rules: [{
                    type : 'empty',
                    prompt: '请输入昵称'
                }]
            },
            email : {
                identifier: 'email',
                rules: [{
                    type : 'empty',
                    prompt : '请输入邮箱'
                },{
                    type : 'email',
                    prompt : '请输入正确的邮箱格式'
                }]
            },
            password : {
                identifier: 'password',
                rules: [{
                    type : 'empty',
                    prompt: '请输入密码'
                }]
            },
            rePassword : {
                identifier: 'rePassword',
                rules: [{
                    type : 'empty',
                    prompt: '请再次输入密码'
                },{
                    type : 'notExactly['+password+']',
                    prompt : '两次密码不一致'
                }]
            }
        }
    });
</script>

</body>
</html>